<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../0js/vue.js"></script>
</head>
<body>

<div id="root">
    <!--遍历数组-->
    <ul>
        <li v-for="(p, index) in persons" :key="p.id">
            {{p.name}} -- {{p.age}}
        </li>
    </ul>
    <hr>
    <ul>
        <li v-for="(p, index) of persons" :key="p.id">
            {{p.name}} -- {{p.age}}
        </li>
    </ul>
    <hr>
    <!--遍历对象-->
    <ul>
        <li v-for="(value, key) in car" :key="key">
            {{value}} -- {{key}}
        </li>
    </ul>
    <hr>
    <!--遍历字符串-->
    <ul>
        <li v-for="(char, index) in str" :key="index">
            {{char}} -- {{index}}
        </li>
    </ul>

    <!--遍历次数-->
    <ul>
        <li v-for="(number, index) in 5" :key="index">
            {{number}} -- {{index}}
        </li>
    </ul>
</div>

<script type="text/javascript">
    // 阻止vue在启动时生成生产提示
    Vue.config.productionTip = false

    const vm = new Vue({
        el: "#root",
        data: {
            name: "vue",
            persons:[
                {id:"001",name:"张三",age:18},
                {id:"002",name:"李四",age:19},
                {id:"003",name:"王五",age:20}
            ],
            car:{
                name:"朗逸",
                price:"10万",
                color:"黑色"
            },
            str:"hello"
        },
        methods: {

        }
    });

</script>
</body>
</html>